package com.pri.chat.adapter;

import android.view.View;
import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.netease.nim.uikit.net.entity.WishXinLuBean;
import com.pri.chat.R;
import com.pri.chat.utils.FriendsCircleImageLayout;
import com.pri.chat.utils.StringUtils;
import com.pri.chat.utils.TimeUtils;
import com.pri.chat.view.ImageViewPlus;
import com.vondear.rxtool.RxDataTool;

import java.util.Arrays;
import java.util.List;

/**
 * 描述：添加类的描述
 *
 * @author
 * @time 2020/4/28
 */
public class WishXinLuAdapter extends BaseQuickAdapter<WishXinLuBean, BaseViewHolder> {

    private OnImageClickListener mOnImageClickListener;
    public void setOnImageClickListener(OnImageClickListener listener) {
        mOnImageClickListener = listener;
    }

    public interface OnImageClickListener {

        void onItemClick(View view,List<String> imgList, int position);
    }

    public WishXinLuAdapter(int layoutResId, @Nullable List<WishXinLuBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, WishXinLuBean item) {
        helper.setText(R.id.content,item.getContent());
        helper.setText(R.id.tv_time, TimeUtils.computeFromNowStr(item.getAddDate()));
        if(!RxDataTool.isEmpty(item.getPicList())){
            List<String> imgList = Arrays.asList(item.getPicList().split(","));
            ((FriendsCircleImageLayout)helper.getView(R.id.circle_layout)).setImageUrls(imgList);
            ((FriendsCircleImageLayout)helper.getView(R.id.circle_layout)).setSpacing(10f);
            ((FriendsCircleImageLayout)helper.getView(R.id.circle_layout)).setOnItemClickListener(new FriendsCircleImageLayout.OnItemClickListener() {
                @Override
                public void onItemClick(View view, int position) {
                    mOnImageClickListener.onItemClick(view,imgList,position);
                }
            });
            helper.getView(R.id.circle_layout).setVisibility(View.VISIBLE);
        }else{
            helper.getView(R.id.circle_layout).setVisibility(View.GONE);
        }
    }
}
